package javat.text;

import static org.junit.Assert.assertEquals;

import java.text.NumberFormat;

import org.junit.Test;

public class NumberFormatTest {

    NumberFormat numberFormat = NumberFormat.getInstance();

    @Test
    public void format() {

        final double testNumber = 1d / 3;
        String formatNumber = numberFormat.format(testNumber);
        assertEquals("0.333", formatNumber);

        numberFormat.setMaximumFractionDigits(5);
        formatNumber = numberFormat.format(testNumber);
        assertEquals("0.33333", formatNumber);

        numberFormat.setMinimumFractionDigits(5);
        formatNumber = numberFormat.format(testNumber);
        assertEquals("0.33333", formatNumber);
    }
}
